﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Me.Prettyprint.Cassandra.Utils
{
    public class TimerContext
    {
        public TimerContext(Timer timer)
        {
            Timer = timer;
            Stopwatch = System.Diagnostics.Stopwatch.StartNew();
        }
        public Timer Timer
        {
            get;
            private set;
        }
        public Stopwatch Stopwatch
        {
            get;
            private set;
        }
        public void Stop()
        {
            Stopwatch.Stop();
            Timer.Update(Stopwatch.ElapsedTicks, TimeUnit.NANOSECONDS);
        }
    }
}
